<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page contentType="text/html;charset=UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">
		<link href="themes/css/ui.common.css" rel="stylesheet" type="text/css" />
		<link href="themes/css/ui.child.css" rel="stylesheet" type="text/css" />
		<link href="themes/css/ui.tips.css" rel="stylesheet" type="text/css" />
		<link href="style/jquery_ui/jquery-ui-1.8.custom.css" rel="stylesheet"
			type="text/css" />
		<link id="skin_css" rel="stylesheet" type="text/css"
			href="themes/css/ui.c.blue.css"></link>
		<link rel="stylesheet" href="themes/default/pagination.css"
			type="text/css"></link>
		<link rel="stylesheet" href="themes/css/ui.validation.css" type="text/css"></link>
		<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
		<script src="Scripts/jquery-ui-1.8.custom.min.js"
			type="text/javascript"></script>
		<script src="Scripts/ui.tips.js" type="text/javascript"></script>
		<script src="Scripts/ui.default.js " type="text/javascript"
			charset="UTF-8"></script>
		<script src="Scripts/ui.admincp.js" type="text/javascript"
			charset="UTF-8"></script>
		<script type="text/javascript" src="Scripts/jquery.json-2.2.min.js"></script>
		<STYLE type="text/css">
		.editorArea {
			display: none;
		}
		</STYLE>
		<script type="text/javascript" src="Scripts/ui.dialogFormHelper.js"></script>
		<script type="text/javascript" src="Scripts/ui.validation.js"></script>
		<script type="text/javascript">
		$(function () {
			//setValidate();
			queryStudent();
		});
		
		function setValidate(){  
	   		$("#form").validatingForm({
	      	  submitButtonId:"#btnSubmit",
	     	  clearErrorsOnFocus:true,
	      	  validateOnBlur:true
	       });
	    }
		
		function queryStudent(){
			var stuNo = $("#stuNo").val();
			$.post("studentInfo!queryByStuNo.action", {"stuNo":stuNo},
			function (data) {
				var jsonData = $.evalJSON(data);
				
				if(jsonData == "-1"){
					clear();
					alert("查无此人");
				}else{
				var avatarId = jsonData.avatarInfo.avatarId;
				var gender = jsonData.stuDetail.gender;
				var grade= jsonData.stuDetail.grade;
				var classNo = jsonData.stuDetail.classNo;
				$("#txt_stuId").val(jsonData.id);
				$("#txt_avatarId").val(jsonData.avatarInfo.avatarId);
				$("#txt_stuNo").text(jsonData.stuNo);
				$("#txt_stuName").val(jsonData.stuName);
				$("#txt_idCard").val(jsonData.stuDetail.idCard);
				$("#dl_gender").val(jsonData.stuDetail.gender);
				if(jsonData.mailInfo != null)
				$("#txt_mail").val(jsonData.mailInfo.mail);
				$("#txt_mailId").val(jsonData.mailInfo.mailId);
				if(jsonData.stuDetail!=null){
					$("#txt_detailId").val(jsonData.stuDetail.id);
					$("#txt_hometown").val(jsonData.stuDetail.hometown);
					$("#dl_politician").val(jsonData.stuDetail.politician);
					$("#txt_telphone").val(jsonData.stuDetail.telphone);
					$("#txt_grade").val(jsonData.stuDetail.grade);
					$("#txt_classNo").val(jsonData.stuDetail.classNo);
					$("#txt_cardId").val(jsonData.stuDetail.cardId);
					if(jsonData.stuDetail.majorInfo != null)
					$("#dl_majorId").val(jsonData.stuDetail.majorInfo.majorId);
					if(jsonData.stuDetail.familyInfo != null){
						$("#txt_familyId").val(jsonData.stuDetail.familyInfo.id);
						$("#txt_fatherName").val(jsonData.stuDetail.familyInfo.fatherName);
						$("#txt_fatherTel").val(jsonData.stuDetail.familyInfo.fatherTel);
						$("#txt_motherName").val(jsonData.stuDetail.familyInfo.motherName);
						$("#txt_motherTel").val(jsonData.stuDetail.familyInfo.motherTel);
						$("#txt_address").val(jsonData.stuDetail.familyInfo.address);
					}
					if(jsonData.stuDetail.scoreInfo != null){
						$("#txt_scoreId").val(jsonData.stuDetail.scoreInfo.id);
						$("#txt_examNo").val(jsonData.stuDetail.scoreInfo.examNo);
						$("#txt_chinese").val(jsonData.stuDetail.scoreInfo.chinese);
						$("#txt_math").val(jsonData.stuDetail.scoreInfo.math);
						$("#txt_english").val(jsonData.stuDetail.scoreInfo.english);
						$("#txt_comprehensive").val(jsonData.stuDetail.scoreInfo.comprehensive);
					}
					if(jsonData.stuDetail.bedInfo != null){
						$("#txt_bedInfo").text(jsonData.stuDetail.bedInfo.bedInfoDetail+"，需更改为：");
					}else{
						$("#txt_bedInfo").text("");
					}
				}
				document.getElementById("img_photo").src = "getPhoto.action?avatarId="+avatarId+"&gender="+gender;
				
				$.post("studentInfo!queryBedInfo.action", {"gender":gender,"classNo":classNo,"grade":grade}, function(data){
						$("#dl_bedInfo").attr("disabled",false);
			            $("#dl_bedInfo").html("").append(data);
				});
				}				
			}); 
		}
		
		function toQuery(){
			if (confirm("确定是否离开？"))  {  
				location.href='studentInfo!toQuery.action';
			}else{ 
				return false;
			};
			
		}
		</script>
	</head>
	<body>
		<div class="PageChild_Title">
			<img src=" themes/images/default/icons/archives.png"
				class="PageChild_Tbtnpic" />
			<span class="PageChild_separate"></span>
			<span class="PageChild_TbtnText">
				<h2>修改学生信息	</h2>
			</span>
			<span class="PageChild_separate"></span>
			<div id="marker" class="red-tips">
			</div>
			<div class="clear">
			</div>
		</div>
		<s:form action="studentInfo!modifyStudentAllByStu.action" method="post" enctype ="multipart/form-data">
		<table  id="form" style="border: 1px solid gray; padding: 1px;" border="0"
			cellpadding="0" cellspacing="0" align="center">
			<tr>
				<td colspan="8" align="center">
					<input id="stuNo" type="hidden" value="${stuNo}">
					<s:hidden id="txt_stuId" name="stuId" theme="simple"/>
					<s:hidden id="txt_mailId" name="mailId" theme="simple"/>
					<s:hidden id="txt_detailId" name="detailId" theme="simple"/>
					<s:hidden id="txt_familyId" name="familyId" theme="simple"/>
					<s:hidden id="txt_scoreId" name="scoreId" theme="simple"/>
					<s:hidden id="txt_avatarId" name="avatarId" theme="simple"/>
				</td>
			</tr>
			<tr>
				<td colspan="8" align="center">
					<b>基本信息</b>
				</td>
			</tr>
			<tr>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;学号:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<label id="txt_stuNo"></label>
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;姓名:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<s:textfield id="txt_stuName" name="stuName" cssClass="control-width-100 required-field no-Chinese-field input-control clearable" theme="simple"/>
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;银行卡号:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<s:textfield id="txt_cardId" name="cardId" cssClass="control-width-100 required-field no-Chinese-field input-control clearable" theme="simple"/>
				</td>
				<td style="width: 300px" valign="middle" align="center" class="style1" rowspan="5" colspan="2">
					<img id="img_photo" alt="一寸照片" src="getPhoto.action"><br />
					&nbsp;照片：<s:file name ="stuPhoto" cssClass="control-width-100 input-control" theme="simple"/>
				</td>
			</tr>
			<tr>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;性别:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<s:select list="#{'男':'男','女':'女'}" headerKey="" headerValue="-请选择-" id="dl_gender" name="gender" theme="simple" cssClass="control-width-40 clearable" cssStyle="width: 152px; height: 26px"></s:select>
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;身份证号:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<s:textfield id="txt_idCard" name="idCard" cssClass="control-width-100 required-field no-Chinese-field input-control clearable" theme="simple"/>
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;邮箱:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<s:textfield id="txt_mail" name="mail" cssClass="control-width-100 required-field no-Chinese-field input-control clearable" theme="simple"/>
				</td>
			</tr>
			<tr>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;家乡:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<s:textfield id="txt_hometown" name="hometown" cssClass="control-width-100 required-field no-Chinese-field input-control clearable" theme="simple"/>
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;政治面貌:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<s:select list="#{'团员':'团员','预备党员':'预备党员','党员':'党员','群众':'群众'}" headerKey="" headerValue="-请选择-" id="dl_politician" name="politician" theme="simple" cssClass="control-width-40 clearable" cssStyle="width: 152px; height: 26px"></s:select>
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;手机号码:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<s:textfield id="txt_telphone" name="telphone" cssClass="control-width-100 required-field no-Chinese-field input-control clearable" theme="simple"/>
				</td>
			</tr>
			<tr>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;专业:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<s:select list="majorInfoList" listKey="majorId" listValue="majorName" headerKey="" headerValue="-请选择-" id="dl_majorId" name="majorId" theme="simple" emptyValueMsg="请选择专业。" emptyValueForValidate="-1" cssClass="selectable-field control-width-40 clearable" cssStyle="width: 152px; height: 26px"></s:select>
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;年级:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<s:textfield id="txt_grade" name="grade" cssClass="control-width-100 required-field no-Chinese-field input-control clearable" theme="simple"/>
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;班级:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<s:textfield id="txt_classNo" name="classNo" cssClass="control-width-100 required-field no-Chinese-field input-control clearable" theme="simple"/>
				</td>
			</tr>
			<tr>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;宿舍床位:
				</td>
				<td style="width: 400px" valign="middle" class="style1" colspan="7">
					<label id="txt_bedInfo"></label><s:select list="{}" id="dl_bedInfo" name="bedId" theme="simple" cssClass="selectable-field control-width-40 clearable" cssStyle="width: 180px; height: 26px" disabled="true"></s:select>
				</td>
			</tr>
			<tr>
				<td colspan="8" align="center">
					<br /><b>家庭信息</b>
				</td>
			</tr>
			<tr>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;父亲姓名:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<s:textfield id="txt_fatherName" name="fatherName" cssClass="control-width-100 required-field no-Chinese-field input-control clearable" theme="simple"/>
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;联系电话:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<s:textfield id="txt_fatherTel" name="fatherTel" cssClass="control-width-100 required-field no-Chinese-field input-control clearable" theme="simple"/>
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;母亲姓名:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<s:textfield id="txt_motherName" name="motherName" cssClass="control-width-100 required-field no-Chinese-field input-control clearable" theme="simple"/>
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;联系电话:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<s:textfield id="txt_motherTel" name="motherTel" cssClass="control-width-100 required-field no-Chinese-field input-control clearable" theme="simple"/>
				</td>
			</tr>
			<tr>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;家庭地址:
				</td>
				<td style="width: 110px" valign="middle" class="style1" colspan="7">
					<s:textfield id="txt_address" name="address" cssClass="control-width-100 required-field no-Chinese-field input-control clearable" theme="simple"/>
				</td>
			</tr>
			<tr>
				<td colspan="8" align="center">
					<br /><b>入学成绩</b>
				</td>
			</tr>
			<tr>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;考号:
				</td>
				<td style="width: 110px" valign="middle" class="style1" colspan="7">
					<s:textfield id="txt_examNo" name="examNo" cssClass="control-width-100 required-field no-Chinese-field input-control clearable" theme="simple"/>
				</td>
			</tr>
			<tr>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;语文:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<s:textfield id="txt_chinese" name="chinese" cssClass="control-width-100 required-field no-Chinese-field input-control clearable" theme="simple"/>
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;数学:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<s:textfield id="txt_math" name="math" cssClass="control-width-100 required-field no-Chinese-field input-control clearable" theme="simple"/>
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;外语:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<s:textfield id="txt_english" name="english" cssClass="control-width-100 required-field no-Chinese-field input-control clearable" theme="simple"/>
				</td>
				<td class="text-align-right" style="width: 80px;">
					&nbsp;综合:
				</td>
				<td style="width: 110px" valign="middle" class="style1">
					<s:textfield id="txt_comprehensive" name="comprehensive" cssClass="control-width-100 required-field no-Chinese-field input-control clearable" theme="simple"/>
				</td>
			</tr>
			<tr>
				<td colspan="8" align="center">
					<input id="btnSubmit" type="submit" class="o-btn" value="提交"/>
					&nbsp;
					<input id="btn_Reset" type="button" value="返回" class="o-btn" onclick="toQuery();" />
				</td>
			</tr>
			<tr>
				<td colspan="8" align="center">
					&nbsp;
				</td>
			</tr>
		</table>
		</s:form>
		<div id="errorSummary"></div>
	</body>
</html>